import { CategoryModel } from '@/api/cms/category/CategoryModel'
import { reactive } from 'vue'

export default function useBaseModel() {
    //表单绑定的数据
    const addModel = reactive<CategoryModel>({
        id: '',
        editType: '',
        parent_id: '',
        name: '',
        sort: '',
        status: ''
    })
    //表单验证规则
    const rules = reactive({
        parent_id: [
            {
                required: true,
                trigger: 'change',
                message: '请选择上级分类'
            }
        ],
        name: [
            {
                required: true,
                trigger: 'blur',
                message: '请填写分类名称'
            },
            { min: 2, max: 50, message: '长度为2-50个字符', trigger: 'blur' }
        ]
    })

    return {
        addModel,
        rules
    }
}
